package com.xz.danhuaapi.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xz.danhuaapi.model.dto.userinterfaceinfo.UserInterfaceInfoAddRequest;
import com.xz.danhuaapi.model.dto.userinterfaceinfo.UserInterfaceInfoQueryRequest;
import com.xz.danhuaapicommon.model.entity.UserInterfaceInfo;


import javax.servlet.http.HttpServletRequest;

/**
* @author xuzhou
* @description 针对表【user_interface_info(用户调用接口关系)】的数据库操作Service
* @createDate 2024-07-04 14:46:33
*/
public interface UserInterfaceInfoService extends IService<UserInterfaceInfo> {
    /**
     * 校验
     *
     * @param userInterfaceInfo
     * @param add
     */
    void validUserInterfaceInfo(UserInterfaceInfo userInterfaceInfo, boolean add);

    /**
     * 添加
     * @param userInterfaceInfoAddRequest
     * @param request
     * @return
     */
    long addUserInterfaceInfo(UserInterfaceInfoAddRequest userInterfaceInfoAddRequest, HttpServletRequest request);

    /**
     * 获取查询条件
     *
     * @param userInterfaceInfoQueryRequest
     * @return
     */
    QueryWrapper<UserInterfaceInfo> getQueryWrapper(UserInterfaceInfoQueryRequest userInterfaceInfoQueryRequest);

    /**
     * 分页获取
     *
     * @param userInterfaceInfoPage
     * @param request
     * @return
     */
    IPage<UserInterfaceInfo> getUserInterfaceInfoPage(Page<UserInterfaceInfo> userInterfaceInfoPage, HttpServletRequest request);

    /**
     * 获取接口调用次数
     *
     * @param interfaceInfoId
     * @param userId
     * @return
     */
    boolean invokeCount(long interfaceInfoId, long userId);

    /**
     * 检测接口剩余调用次数
     *
     * @param interfaceInfoId
     * @param userId
     * @return
     */
    UserInterfaceInfo getInvokeUserInterfaceInfo(long interfaceInfoId, long userId);
}
